const {
  $util,
} = getApp();
let isPrevImg = false;
Page({
  data: {},
  onLoad(opts) {
    console.log('onLoad');
    this.setData({
      id: opts.id,
    });
    this.loadDetail(opts.id);
    wx.setNavigationBarTitle({
      title: opts.barTitle && decodeURIComponent(opts.barTitle) || '公益事业详情',
    });
  },
  onShow() {
    if (isPrevImg) {
      isPrevImg = false;
      return;
    }
    console.log('onShow');
  },
  onHide() {
    console.log('onHIde');
  },
  /**
   * 阻止预览图片时触发onShow
   */
  onPrevImg() {
    isPrevImg = true;
  },
  loadDetail(id) {
    $util.request({
      url: 'entry/wxapp/partyman.home.getcareerdetails',
      data: {
        id,
      },
      success: (res) => {
        this.setData({
          detail: res.data,
        });
      },
    });
  },
});
